package com.hzy.friend.entity;

import lombok.*;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;

/**
 * mongodb示例实体类
 * <p>
 * Create by chenwei on 2018/11/21 17:54
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Builder
@Document(collection = "t_user")
@CompoundIndexes({
        @CompoundIndex(name = "userId_createTime", def = "{'userId': 1, 'createTime': -1}")
})
public class User implements Serializable {


    private static final long serialVersionUID = -7531825668856476152L;

    @Id
    public String userId;

    public String name;


    public Integer age;

    /**
     * 该注解让字段不持久化到数据库中
     */
    public Long createTime;

    /**
     * 该注解让字段不持久化到数据库中
     */
    public Long updateTime;


    /**
     * 排序字段
     */
    @Transient
    public Long sortNumber;
    //批量操作主键id集合
    @Transient
    private String ids;
    //搜索关键字
    @Transient
    private String keyword;
    //搜索开始时间
    @Transient
    private Long searchStartTime;
    //搜索结束时间
    @Transient
    private Long searchEndTime;
}
